<template>
  <div class="wapper">
    <swiper :options="swiperOption" v-if='showSwiper'>
      <!-- slides -->
      <swiper-slide v-for="item in list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" alt />
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "HomeSwiper",
  props: {
    list: Array
  },
  data() {
    return {
      // swiperList: [
      //   {
      //     id: '001',
      //     imgUrl:
      //       "http://img1.qunarzz.com/piao/fusion/1802/e3/62ce7362ca051d02.jpg_640x200_6db551b7.jpg"
      //   },
      //   {
      //     id: '002',
      //     imgUrl:
      //       "http://img1.qunarzz.com/piao/fusion/1801/93/ce59d182aca07102.jpg_640x200_ba03d44c.jpg"
      //   }
      // ],
      swiperOption: {
        pagination: {
          el: ".swiper-pagination",
        },
        loop: true,
        autoplay: true
      }
    };
  },
  computed: {
    showSwiper() {
      return this.list.length
    }
  },
};
</script>

<style lang='less' scoped>
.wapper /deep/ .swiper-pagination-bullet-active {
  background: #fff !important;
}
.wapper {
  overflow: hidden;
  width: 100%;
  height: 30vw;
  background: #ccc;
  .swiper-img {
    width: 100%;
  }
}
</style>
